<script type="text/javascript">
function multiDelete()
{
  return confirm("<?php echo $this->translate('Are you sure you want to delete the selected forms?');?>");
}

function selectAll()
{
  var i;
  var multidelete_form = $('multidelete_form');
  var inputs = multidelete_form.elements;
  for (i = 1; i < inputs.length; i++) {
    if (!inputs[i].disabled) {
      inputs[i].checked = inputs[0].checked;
    }
  }
}
</script>
<h2>
  <?php echo $this->translate('Form Creator Plugin') ?>
</h2>
<?php if( count($this->navigation) ): ?>
  <div class='tabs'>
    <?php
      // Render the menu
      //->setUlClass()
      echo $this->navigation()->menu()->setContainer($this->navigation)->render()
    ?>
  </div>
<?php endif; ?>
<div style="margin-bottom: 10px;">
<?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'frmcreator', 'controller' => 'manage', 'action' => 'add-form'), $this->translate('Add New Form'), array(
      'class' => 'buttonlink',
      'style' => 'background-image: url(' . $this->layout()->staticBaseUrl . 'application/modules/Core/externals/images/admin/new_category.png);')) ?>
</div>
<?php if( count($this->paginator) ): ?>
<form id='multidelete_form' method="post" action="<?php echo $this->url();?>" onSubmit="return multiDelete()">
<table class='admin_table'>
  <thead>
    <tr>
      <th class='admin_table_short'><input onclick='selectAll();' type='checkbox' class='checkbox' /></th>
      <th class='admin_table_short'>ID</th>
      <th><?php echo $this->translate("Title") ?></th>
      <th><?php echo $this->translate("Url") ?></th>
      <th><?php echo $this->translate("Sent Email") ?></th>
      <!--
      <th><?php echo $this->translate("Date") ?></th>
      -->
        <th><?php echo $this->translate("Status") ?></th>
      <th><?php echo $this->translate("Options") ?></th>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($this->paginator as $item): ?>
      <tr>
        <td><input type='checkbox' class='checkbox' name='delete_<?php echo $item->getIdentity(); ?>' value="<?php echo $item->getIdentity(); ?>" /></td>
        <td><?php echo $item->getIdentity(); ?></td>
        <td><?php echo $item->getTitle(); ?></td>
        <td><?php echo $this->htmlLink($item,$item->getTitle(), array('target' => '_blank')); ?></td>
        <td><?php echo $item->email; ?></td>
        <!--
        <td><?php echo $this->locale()->toDateTime($item->creation_date) ?></td>
        -->
		<td><?php echo $item->getStatusLabel(); ?></td>
        <td>
            <?php echo $this->htmlLink(
                array('route' => 'admin_default', 'module' => 'frmcreator', 'controller' => 'manage', 'action' => 'edit-form', 'id' => $item->form_id),
                '<img src="./application/modules/Frmcreator/externals/images/edit.png" />',
                array()) ?>          
          <?php echo $this->htmlLink(
                array('route' => 'admin_default', 'module' => 'frmcreator', 'controller' => 'manage', 'action' => 'delete-form', 'id' => $item->form_id),
                '<img src="./application/modules/Frmcreator/externals/images/delete.png" />',
                array('class' => 'smoothbox')) ?>
          <?php
                if($item->status):
                    echo $this->htmlLink(
                    array('route' => 'admin_default', 'module' => 'frmcreator', 'controller' => 'manage', 'action' => 'inactive-form', 'id' => $item->form_id),
                    '<img src="./application/modules/Frmcreator/externals/images/active.png" title="Disable Form" />',
                    array('class' => 'smoothbox'));
                else:
                    echo $this->htmlLink(
                    array('route' => 'admin_default', 'module' => 'frmcreator', 'controller' => 'manage', 'action' => 'active-form', 'id' => $item->form_id),
                    '<img src="./application/modules/Frmcreator/externals/images/inactive.png" title="Enable Form" />',
                    array('class' => 'smoothbox'));
                endif;
          ?>
        </td>
      </tr>
    <?php endforeach; ?>
  </tbody>
</table>

<br />

<div class='buttons'>
  <button type='submit'><?php echo $this->translate("Delete Selected") ?></button>
</div>
</form>

<br/>
<div>
  <?php echo $this->paginationControl($this->paginator); ?>
</div>

<?php else: ?>
  <div class="tip">
    <span>
      <?php echo $this->translate("There are no form created yet.") ?>
    </span>
  </div>
<?php endif; ?>
